/*
 * @lc app=leetcode.cn id=1309 lang=typescript
 *
 * [1309] 解码字母到整数映射
 */

// @lc code=start
function freqAlphabets(s: string): string {
    let result: string[] = [];
    for (let i = s.length - 1; i >= 0; i--) {
        const element = s[i];
        if (element === "#") {
            result.unshift(s.slice(i - 2, i));
            i = i - 2;
        } else {
            result.unshift(element);
        }
    }
    return String.fromCharCode(
        ...result.map((i) => {
            return parseInt(i) + 96;
        })
    );
}
// @lc code=end
